<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="产品名称" prop="productName">
        <el-input
          v-model="queryParams.productName"
          placeholder="请输入产品名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="生产工单" prop="prodorderNo">
        <el-input
          v-model="queryParams.prodorderNo"
          placeholder="请输入生产工单"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="cyan"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="ready"
          >备料</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-plus"
          size="mini"
          :disabled="single"
          @click="upFrom"
          v-hasPermi="['prodmanage:mworkorder:loading']"
          >上料</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['prodmanage:mworkorder:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <!-- <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['prodmanage:mworkorder:edit']"
          >修改</el-button
        > -->
      </el-col>
      <el-col :span="1.5">
        <!-- <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['prodmanage:mworkorder:remove']"
          >删除</el-button
        > -->
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['prodmanage:mworkorder:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="mworkorderList"
      @selection-change="handleSelectionChange"
      :default-sort="{ prop: 'date', order: 'descending' }"
      ref="tableDatas"
      border
      
    >
      <el-table-column type="selection" width="55" align="center" sortable />
      <!-- <el-table-column
        label="调拨状态"
        align="center"
        prop="transferStatus"
        sortable
        width="150"
        :formatter="transferStatusFormat"
      />
      <el-table-column
        label="单据状态"
        align="center"
        prop="documentStatus"
        sortable
        width="150"
        :formatter="documentStatusFormat"
      /> -->
      <el-table-column
        label="生产工单号"
        align="center"
        prop="prodorderNo"
        sortable
        
         :show-overflow-tooltip="true"
      >
  <template slot-scope="scope">

          <span v-show="IsHidden(scope.$index)">{{scope.row.prodorderNo}}</span>
        </template>
  </el-table-column>

      <el-table-column
        label="工单类型"
        align="center"
        prop="workorderType"
        sortable
        
        :formatter="workorderTypeFormat"
         :show-overflow-tooltip="true"
      >
      <template slot-scope="scope">

          <span v-show="IsHidden(scope.$index)">{{capitalize(scope.row.workorderType)}}</span>
        </template>
</el-table-column>
    <el-table-column 
        label="产品编码"
        align="center"
        prop="productCode"
        sortable
        
         :show-overflow-tooltip="true"
        >
        <template slot-scope="scope">

          <span v-show="IsHidden(scope.$index)">{{scope.row.productCode}}</span>
        </template>
      </el-table-column>
      
      <el-table-column
        label="产品名称"
        align="center"
        prop="productName"
        sortable
        
         :show-overflow-tooltip="true"
      >
       <template slot-scope="scope">

          <span v-show="IsHidden(scope.$index)">{{scope.row.productName}}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="规格型号"
        align="center"
        prop="specModel"
        sortable
        
         :show-overflow-tooltip="true"
      >
      <template slot-scope="scope">

          <span v-show="IsHidden(scope.$index)">{{scope.row.specModel}}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="数量"
        align="center"
        prop="quantity"
        sortable
        
         :show-overflow-tooltip="true"
      >

        <template slot-scope="scope">

          <span v-show="IsHidden(scope.$index)">{{scope.row.quantity}}</span>
        </template>
  </el-table-column>
      <el-table-column
        label="单位"
        align="center"
        prop="unit"
        sortable
        
         :show-overflow-tooltip="true"
      >

      
        <template slot-scope="scope">

          <span v-show="IsHidden(scope.$index)">{{scope.row.unit}}</span>
        </template>
  </el-table-column>
      <el-table-column
        label="车间"
        align="center"
        prop="workshop"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="物料编码"
        align="center"
        prop="goodsCode"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="物料名称"
        align="center"
        prop="goodsName"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="物料规格型号"
        align="center"
        prop="goodsModel"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="物料单位"
        align="center"
        prop="goodsUnit"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="单位用量"
        align="center"
        prop="unitDosage"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="标准用量"
        align="center"
        prop="standardDosage"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="应发数量"
        align="center"
        prop="issuedQuantity"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="已领数量"
        align="center"
        prop="receivedQuantity"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="备料数量"
        align="center"
        prop="investedQuantity"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="可用库存"
        align="center"
        prop="avaInventory"
        sortable
        
         :show-overflow-tooltip="true"
      />

      <el-table-column
        label="报废数量"
        align="center"
        prop="scrapQuantity"
        sortable
        
         :show-overflow-tooltip="true"
      >
        <template slot-scope="scope">

          <span v-show="IsHidden(scope.$index)">{{scope.row.scrapQuantity}}</span>
        </template>
  </el-table-column>
      <el-table-column
        label="补料数量"
        align="center"
        prop="replenQuantity"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="损耗率"
        align="center"
        prop="lossRate"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="物料类型"
        align="center"
        prop="goodsType"
        sortable
        
        :formatter="goodsTypeFormat" 
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="投料单号"
        align="center"
        prop="goodsStagingno"
        sortable
        
         :show-overflow-tooltip="true"
      >
       <template slot-scope="scope">

          <span v-show="IsHidden(scope.$index)">{{scope.row.goodsStagingno}}</span>
        </template>
  </el-table-column>
      <el-table-column
        label="销售订单号"
        align="center"
        prop="saleNum"
        sortable
        
         :show-overflow-tooltip="true"
      >
         <template slot-scope="scope">

          <span v-show="IsHidden(scope.$index)">{{scope.row.saleNum}}</span>
        </template>
  </el-table-column>
      <el-table-column
        label="计划单号"
        align="center"
        prop="playNo"
        sortable
        
         :show-overflow-tooltip="true"
      >
        <template slot-scope="scope">

          <span v-show="IsHidden(scope.$index)">{{scope.row.playNo}}</span>
        </template>
  </el-table-column>
      <el-table-column
        label="计划发料日期"
        align="center"
        prop="plannedIssuedate"
        
         :show-overflow-tooltip="true"
        sortable
      >
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.plannedIssuedate, "{y}-{m}-{d}")
          }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="实际发料日期"
        align="center"
        prop="actualIssuedate"
        
        sortable
         :show-overflow-tooltip="true"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.actualIssuedate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="制单日期"
        align="center"
        prop="preparationDate"
        
        sortable
         :show-overflow-tooltip="true"
      >
        <template slot-scope="scope">
          <span v-show="IsHidden(scope.$index)">{{ parseTime(scope.row.preparationDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="备料状态"
        align="center"
        prop="stockState"
        sortable
        
        :formatter="stockStateFormat"
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="发料仓库"
        align="center"
        prop="issueWarehouse"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="发料人"
        align="center"
        prop="issuedBy"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="发料时间"
        align="center"
        prop="issueTime"
        
        sortable
       :show-overflow-tooltip="true"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.issueTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="收料仓库"
        align="center"
        prop="receiveWarehouse"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="收料人"
        align="center"
        prop="receiveBy"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="收料时间"
        align="center"
        prop="receiveTime"
        
        sortable
         :show-overflow-tooltip="true"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.receiveTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="备注"
        align="center"
        prop="remark"
        sortable
        
         :show-overflow-tooltip="true"
      />
      <!-- <el-table-column label="产品id" align="center" prop="productId" />
      <el-table-column label="审核标志" align="center" prop="auditMark" sortable width="150"/>
      <el-table-column label="审核人" align="center" prop="auditMan" sortable width="150"/>
      <el-table-column label="审核日期" align="center" prop="auditDate" width="150" sortable>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.auditDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column
      <el-table-column label="总报工数" align="center" prop="totalreportNum" sortable width="150"/>
      <el-table-column label="已报工数" align="center" prop="alreadyreportNum" sortable width="150"/>
      <el-table-column label="已入库总数" align="center" prop="totalstoresNum" sortable width="150"/>
      <el-table-column label="已入良品数" align="center" prop="goodNum" sortable width="150"/>
      <el-table-column label="已入不良品数" align="center" prop="badNum" sortable width="150"/>
      <el-table-column label="来源" align="center" prop="source" sortable width="150"/>
      <el-table-column label="创建时间" align="center" prop="createTime" width="150" sortable>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建人" align="center" prop="createUser" />
      <el-table-column label="修改时间" align="center" prop="updateTime" width="150" sortable>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="修改人" align="center" prop="updateUser" sortable width="150"/>
      <el-table-column label="单据状态(1=创建，2=完成)" align="center" prop="workorderId" />
      <el-table-column label="物料id" align="center" prop="goodsId" />
      <el-table-column label="应投数量" align="center" prop="investedQuantity" />
      <el-table-column label="执行状态" align="center" prop="exeStatus" />
      <el-table-column label="生产类型(0普通订单，1新增订单，2MRP拉取)" align="center" prop="prodType" />
      <el-table-column label="状态类型(0=良品 1=不良品 2=待检品)" align="center" prop="stateType" /> 
      <el-table-column label="订单号" align="center" prop="orderNum" />
      <el-table-column label="级别名称" align="center" prop="levelName" />
      <el-table-column label="常用单位" align="center" prop="commentUnit" />
      <el-table-column label="标准用量" align="center" prop="standardNum" />
      <el-table-column label="计划投料数量" align="center" prop="planfeedNum" />
      <el-table-column label="选单数量" align="center" prop="menuNum" />
      <el-table-column label="基本单位已领数量" align="center" prop="basicunitInnum" />
      <el-table-column label="在制品数量" align="center" prop="inworkNum" />
      <el-table-column label="消耗数量" align="center" prop="consumNum" />
      <el-table-column label="倒冲" align="center" prop="recoil" />
      <el-table-column label="批次" align="center" prop="batch" />
      <el-table-column label="订单行号" align="center" prop="lineorderCode" />
      <el-table-column label="分录号" align="center" prop="entryNum" />
      <el-table-column label="基本单位数量" align="center" prop="basicunitNum" />
      <el-table-column label="常用单位数量" align="center" prop="commentunitNum" />
      <el-table-column label="加工单位" align="center" prop="workcompany" />
      <el-table-column label="禁用" align="center" prop="forbidden" />
      <el-table-column label="子项物料类型" align="center" prop="subgoodsType" />
      <el-table-column label="子项物料代码" align="center" prop="subgoodsCode" />
      <el-table-column label="基本单位" align="center" prop="basicUnit" />
      <el-table-column label="关键件" align="center" prop="keyParts" />
      <el-table-column label="使用状态" align="center" prop="useStatus" />
      <el-table-column label="基本单位用量" align="center" prop="basicunitDosage" />
      <el-table-column label="基本单位应发数量" align="center" prop="basicunitOutnum" />
      <el-table-column label="基本单位标准用量" align="center" prop="basicunitBzdosage" />
      <el-table-column label="实际损耗率" align="center" prop="realLossrate" />
      <el-table-column label="基本单位损耗数量" align="center" prop="basicLossnum" />
      <el-table-column label="损耗数量" align="center" prop="lossnum" />
      <el-table-column label="基本单位计划投料数量" align="center" prop="basicplanNum" />
      <el-table-column label="基本单位单数量" align="center" prop="basicunitQuantity" />
      <el-table-column label="基本单位报废数量" align="center" prop="basicunitScrapnum" />
      <el-table-column label="报废数量" align="center" prop="scrapnum" />
      <el-table-column label="基本单位消耗数量" align="center" prop="basicunitConsumnum" />
      <el-table-column label="基本单位在制品数量" align="center" prop="basicunitInworknum" />
      <el-table-column label="工序" align="center" prop="workProcess" />
      <el-table-column label="工位" align="center" prop="workStation" />
      <el-table-column label="锁库标志" align="center" prop="lockFlag" />
      <el-table-column label="锁库数量" align="center" prop="lockNum" />
      <el-table-column label="基本单位锁库数量" align="center" prop="basicunitLocknum" />
      <el-table-column label="基本单位补料数量" align="center" prop="basicunitUpnum" />
      <el-table-column label="补料数量" align="center" prop="makeupNum" />
      <el-table-column label="工序号" align="center" prop="processNum" />
      <el-table-column label="客户BOM编号" align="center" prop="customerBom" />
      <el-table-column label="调拨数量" align="center" prop="allocatedQuantity" />
      <el-table-column label="基本单位调拨数量" align="center" prop="allocatedNum" />
      <el-table-column label="调拨选单数量" align="center" prop="transferQuantity" />
      <el-table-column label="基本单位调拨选单数量" align="center" prop="transferNum" />
      <el-table-column label="变更次数" align="center" prop="becomeQuantity" />
      <el-table-column label="计划模式" align="center" prop="planMode" />
      <el-table-column label="打印次数" align="center" prop="printNumber" />
      <el-table-column label="计划跟踪单号" align="center" prop="teackNumber" />
      <el-table-column label="位置号" align="center" prop="locationNumber" />
      <el-table-column label="还料尺寸" align="center" prop="returnDimension" />
      <el-table-column label="还料数" align="center" prop="returnQuantity" />
      <el-table-column label="产品辅助属性" align="center" prop="productProperties" />
      <el-table-column label="产品辅助属性代码" align="center" prop="propertiesCode" />
      <el-table-column label="物料辅助属性" align="center" prop="materialProperties" />
      <el-table-column label="物料辅助属性代码" align="center" prop="materialCode" />
      <el-table-column label="下达车间" align="center" prop="releaseWorkshop" />
      <el-table-column label="客户料号" align="center" prop="customerItem" />
      <el-table-column label="助记码" align="center" prop="mnemonicCode" /> -->
      <!-- <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
         :show-overflow-tooltip="true"
      >
         <template slot-scope="scope">
         <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['prodmanage:mworkorder:edit']"
            >修改</el-button
          > 
           <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['prodmanage:mworkorder:remove']"
            >删除</el-button
          >  
        </template>
      </el-table-column> -->
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 添加或修改投料管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item
          label="工单类型(0正常，1超产，2返工)"
          prop="workorderType"
        >
          <el-select
            v-model="form.workorderType"
            placeholder="请选择工单类型(0正常，1超产，2返工)"
          >
            <el-option
              v-for="dict in workorderTypeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="产品id" prop="productId">
          <el-input v-model="form.productId" placeholder="请输入产品id" />
        </el-form-item>
        <el-form-item label="产品编码" prop="productCode">
          <el-input v-model="form.productCode" placeholder="请输入产品编码" />
        </el-form-item>
        <el-form-item label="产品名称" prop="productName">
          <el-input v-model="form.productName" placeholder="请输入产品名称" />
        </el-form-item>
        <el-form-item label="规格型号" prop="specModel">
          <el-input v-model="form.specModel" placeholder="请输入规格型号" />
        </el-form-item>
        <el-form-item label="单位" prop="unit">
          <el-input v-model="form.unit" placeholder="请输入单位" />
        </el-form-item>
        <el-form-item label="车间" prop="workshop">
          <el-input v-model="form.workshop" placeholder="请输入车间" />
        </el-form-item>
        <el-form-item label="审核标志" prop="auditMark">
          <el-select v-model="form.auditMark" placeholder="请选择审核标志">
            <el-option
              v-for="dict in auditMarkOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="审核人" prop="auditMan">
          <el-input v-model="form.auditMan" placeholder="请输入审核人" />
        </el-form-item>
        <el-form-item label="审核日期" prop="auditDate">
          <el-date-picker
            clearable
            size="small"
            style="width: 200px"
            v-model="form.auditDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择审核日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="数量" prop="quantity">
          <el-input v-model="form.quantity" placeholder="请输入数量" />
        </el-form-item>
        <el-form-item label="物料id" prop="goodsId">
          <el-input v-model="form.goodsId" placeholder="请输入物料id" />
        </el-form-item>
        <el-form-item label="物料名称" prop="goodsName">
          <el-input v-model="form.goodsName" placeholder="请输入物料名称" />
        </el-form-item>
        <el-form-item label="物料规格型号" prop="goodsModel">
          <el-input
            v-model="form.goodsModel"
            placeholder="请输入物料规格型号"
          />
        </el-form-item>
        <el-form-item label="物料编码" prop="goodsCode">
          <el-input v-model="form.goodsCode" placeholder="请输入物料编码" />
        </el-form-item>
        <el-form-item label="物料单位" prop="goodsUnit">
          <el-input v-model="form.goodsUnit" placeholder="请输入物料单位" />
        </el-form-item>
        <el-form-item label="应投数量" prop="investedQuantity">
          <el-input
            v-model="form.investedQuantity"
            placeholder="请输入应投数量"
          />
        </el-form-item>
        <el-form-item label="单位用量" prop="unitDosage">
          <el-input v-model="form.unitDosage" placeholder="请输入单位用量" />
        </el-form-item>
        <el-form-item label="执行状态" prop="exeStatus">
          <el-select v-model="form.exeStatus" placeholder="请选择执行状态">
            <el-option
              v-for="dict in exeStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="单据状态(0正常，1挂起，2关闭)" prop="docStatus">
          <el-select
            v-model="form.docStatus"
            placeholder="请选择单据状态(0正常，1挂起，2关闭)"
          >
            <el-option
              v-for="dict in docStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="生产类型(0普通订单，1新增订单，2MRP拉取)"
          prop="prodType"
        >
          <el-select
            v-model="form.prodType"
            placeholder="请选择生产类型(0普通订单，1新增订单，2MRP拉取)"
          >
            <el-option
              v-for="dict in prodTypeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="标准用量" prop="standardDosage">
          <el-input
            v-model="form.standardDosage"
            placeholder="请输入标准用量"
          />
        </el-form-item>
        <el-form-item label="应发数量" prop="issuedQuantity">
          <el-input
            v-model="form.issuedQuantity"
            placeholder="请输入应发数量"
          />
        </el-form-item>
        <el-form-item label="已领数量" prop="receivedQuantity">
          <el-input
            v-model="form.receivedQuantity"
            placeholder="请输入已领数量"
          />
        </el-form-item>
        <el-form-item label="报废数量" prop="scrapQuantity">
          <el-input v-model="form.scrapQuantity" placeholder="请输入报废数量" />
        </el-form-item>
        <el-form-item label="补料数量" prop="replenQuantity">
          <el-input
            v-model="form.replenQuantity"
            placeholder="请输入补料数量"
          />
        </el-form-item>
        <el-form-item label="损耗率" prop="lossRate">
          <el-input v-model="form.lossRate" placeholder="请输入损耗率" />
        </el-form-item>

        </el-form-item>
        <el-form-item label="生产工单号" prop="prodorderNo">
          <el-input v-model="form.prodorderNo" placeholder="请输入生产工单号" />
        </el-form-item>
        <el-form-item label="投料单号" prop="goodsStagingno">
          <el-input
            v-model="form.goodsStagingno"
            placeholder="请输入投料单号"
          />
        </el-form-item>
        <el-form-item label="销售订单号" prop="saleNum">
          <el-input v-model="form.saleNum" placeholder="请输入销售订单号" />
        </el-form-item>
        <el-form-item label="计划单号" prop="playNo">
          <el-input v-model="form.playNo" placeholder="请输入计划单号" />
        </el-form-item>
        <el-form-item label="计划发料日期" prop="plannedIssuedate">
          <el-date-picker
            clearable
            size="small"
            style="width: 200px"
            v-model="form.plannedIssuedate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择计划发料日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="实际发料日期" prop="actualIssuedate">
          <el-date-picker
            clearable
            size="small"
            style="width: 200px"
            v-model="form.actualIssuedate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择实际发料日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="制单日期" prop="preparationDate">
          <el-date-picker
            clearable
            size="small"
            style="width: 200px"
            v-model="form.preparationDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择制单日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item
          label="状态类型(0=良品 1=不良品 2=待检品)"
          prop="stateType"
        >
          <el-select
            v-model="form.stateType"
            placeholder="请选择状态类型(0=良品 1=不良品 2=待检品)"
          >
            <el-option
              v-for="dict in stateTypeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
       <el-form-item label="备料状态" prop="stockState">
          <el-select v-model="form.stockState" placeholder="请选择备料状态">
            <el-option
              v-for="dict in stockStateOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="发料仓库" prop="issueWarehouse">
              <el-select
                v-model="form.lssuingWarehouse"
                placeholder="请选择发料仓库"
              >
                <el-option
                  v-for="dict in WarehouseOptions"
                  :key="dict.name"
                  :label="dict.name"
                  :value="dict.name"
                ></el-option>
              </el-select>
        </el-form-item>
        <el-form-item label="发料人" prop="issuedBy">
          <el-input v-model="form.issuedBy" placeholder="请输入发料人" />
        </el-form-item>
        <el-form-item label="发料时间" prop="issueTime">
          <el-date-picker
            clearable
            size="small"
            style="width: 200px"
            v-model="form.issueTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择发料时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="收料仓库" prop="receiveWarehouse">
          <el-input
            v-model="form.receiveWarehouse"
            placeholder="请输入收料仓库"
          />
        </el-form-item>
        <el-form-item label="收料人" prop="receiveBy">
          <el-input v-model="form.receiveBy" placeholder="请输入收料人" />
        </el-form-item>
        <el-form-item label="收料时间" prop="receiveTime">
          <el-date-picker
            clearable
            size="small"
            style="width: 200px"
            v-model="form.receiveTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择收料时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="订单号" prop="orderNum">
          <el-input v-model="form.orderNum" placeholder="请输入订单号" />
        </el-form-item>
        <el-form-item label="级别名称" prop="levelName">
          <el-input v-model="form.levelName" placeholder="请输入级别名称" />
        </el-form-item>
        <el-form-item label="常用单位" prop="commentUnit">
          <el-input v-model="form.commentUnit" placeholder="请输入常用单位" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input
            v-model="form.remark"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="标准用量" prop="standardNum">
          <el-input v-model="form.standardNum" placeholder="请输入标准用量" />
        </el-form-item>
        <el-form-item label="计划投料数量" prop="planfeedNum">
          <el-input
            v-model="form.planfeedNum"
            placeholder="请输入计划投料数量"
          />
        </el-form-item>
        <el-form-item label="选单数量" prop="menuNum">
          <el-input v-model="form.menuNum" placeholder="请输入选单数量" />
        </el-form-item>
        <el-form-item label="基本单位已领数量" prop="basicunitInnum">
          <el-input
            v-model="form.basicunitInnum"
            placeholder="请输入基本单位已领数量"
          />
        </el-form-item>
        <el-form-item label="在制品数量" prop="inworkNum">
          <el-input v-model="form.inworkNum" placeholder="请输入在制品数量" />
        </el-form-item>
        <el-form-item label="消耗数量" prop="consumNum">
          <el-input v-model="form.consumNum" placeholder="请输入消耗数量" />
        </el-form-item>
        <el-form-item label="倒冲" prop="recoil">
          <el-input v-model="form.recoil" placeholder="请输入倒冲" />
        </el-form-item>
        <el-form-item label="批次" prop="batch">
          <el-input v-model="form.batch" placeholder="请输入批次" />
        </el-form-item>
        <el-form-item label="订单行号" prop="lineorderCode">
          <el-input v-model="form.lineorderCode" placeholder="请输入订单行号" />
        </el-form-item>
        <el-form-item label="分录号" prop="entryNum">
          <el-input v-model="form.entryNum" placeholder="请输入分录号" />
        </el-form-item>
        <el-form-item label="基本单位数量" prop="basicunitNum">
          <el-input
            v-model="form.basicunitNum"
            placeholder="请输入基本单位数量"
          />
        </el-form-item>
        <el-form-item label="常用单位数量" prop="commentunitNum">
          <el-input
            v-model="form.commentunitNum"
            placeholder="请输入常用单位数量"
          />
        </el-form-item>
        <el-form-item label="加工单位" prop="workcompany">
          <el-input v-model="form.workcompany" placeholder="请输入加工单位" />
        </el-form-item>
        <el-form-item label="禁用" prop="forbidden">
          <el-input v-model="form.forbidden" placeholder="请输入禁用" />
        </el-form-item>
        <el-form-item label="子项物料类型" prop="subgoodsType">
          <el-select
            v-model="form.subgoodsType"
            placeholder="请选择子项物料类型"
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="子项物料代码" prop="subgoodsCode">
          <el-input
            v-model="form.subgoodsCode"
            placeholder="请输入子项物料代码"
          />
        </el-form-item>
        <el-form-item label="基本单位" prop="basicUnit">
          <el-input v-model="form.basicUnit" placeholder="请输入基本单位" />
        </el-form-item>
        <el-form-item label="关键件" prop="keyParts">
          <el-input v-model="form.keyParts" placeholder="请输入关键件" />
        </el-form-item>
        <el-form-item label="使用状态">
          <el-radio-group v-model="form.useStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="基本单位用量" prop="basicunitDosage">
          <el-input
            v-model="form.basicunitDosage"
            placeholder="请输入基本单位用量"
          />
        </el-form-item>
        <el-form-item label="基本单位应发数量" prop="basicunitOutnum">
          <el-input
            v-model="form.basicunitOutnum"
            placeholder="请输入基本单位应发数量"
          />
        </el-form-item>
        <el-form-item label="基本单位标准用量" prop="basicunitBzdosage">
          <el-input
            v-model="form.basicunitBzdosage"
            placeholder="请输入基本单位标准用量"
          />
        </el-form-item>
        <el-form-item label="实际损耗率" prop="realLossrate">
          <el-input
            v-model="form.realLossrate"
            placeholder="请输入实际损耗率"
          />
        </el-form-item>
        <el-form-item label="基本单位损耗数量" prop="basicLossnum">
          <el-input
            v-model="form.basicLossnum"
            placeholder="请输入基本单位损耗数量"
          />
        </el-form-item>
        <el-form-item label="损耗数量" prop="lossnum">
          <el-input v-model="form.lossnum" placeholder="请输入损耗数量" />
        </el-form-item>
        <el-form-item label="基本单位计划投料数量" prop="basicplanNum">
          <el-input
            v-model="form.basicplanNum"
            placeholder="请输入基本单位计划投料数量"
          />
        </el-form-item>
        <el-form-item label="基本单位单数量" prop="basicunitQuantity">
          <el-input
            v-model="form.basicunitQuantity"
            placeholder="请输入基本单位单数量"
          />
        </el-form-item>
        <el-form-item label="基本单位报废数量" prop="basicunitScrapnum">
          <el-input
            v-model="form.basicunitScrapnum"
            placeholder="请输入基本单位报废数量"
          />
        </el-form-item>
        <el-form-item label="报废数量" prop="scrapnum">
          <el-input v-model="form.scrapnum" placeholder="请输入报废数量" />
        </el-form-item>
        <el-form-item label="基本单位消耗数量" prop="basicunitConsumnum">
          <el-input
            v-model="form.basicunitConsumnum"
            placeholder="请输入基本单位消耗数量"
          />
        </el-form-item>
        <el-form-item label="基本单位在制品数量" prop="basicunitInworknum">
          <el-input
            v-model="form.basicunitInworknum"
            placeholder="请输入基本单位在制品数量"
          />
        </el-form-item>
        <el-form-item label="工序" prop="workProcess">
          <el-input v-model="form.workProcess" placeholder="请输入工序" />
        </el-form-item>
        <el-form-item label="工位" prop="workStation">
          <el-input v-model="form.workStation" placeholder="请输入工位" />
        </el-form-item>
        <el-form-item label="锁库标志" prop="lockFlag">
          <el-input v-model="form.lockFlag" placeholder="请输入锁库标志" />
        </el-form-item>
        <el-form-item label="锁库数量" prop="lockNum">
          <el-input v-model="form.lockNum" placeholder="请输入锁库数量" />
        </el-form-item>
        <el-form-item label="基本单位锁库数量" prop="basicunitLocknum">
          <el-input
            v-model="form.basicunitLocknum"
            placeholder="请输入基本单位锁库数量"
          />
        </el-form-item>
        <el-form-item label="基本单位补料数量" prop="basicunitUpnum">
          <el-input
            v-model="form.basicunitUpnum"
            placeholder="请输入基本单位补料数量"
          />
        </el-form-item>
        <el-form-item label="补料数量" prop="makeupNum">
          <el-input v-model="form.makeupNum" placeholder="请输入补料数量" />
        </el-form-item>
        <el-form-item label="工序号" prop="processNum">
          <el-input v-model="form.processNum" placeholder="请输入工序号" />
        </el-form-item>
        <el-form-item label="客户BOM编号" prop="customerBom">
          <el-input
            v-model="form.customerBom"
            placeholder="请输入客户BOM编号"
          />
        </el-form-item>
        <el-form-item label="调拨数量" prop="allocatedQuantity">
          <el-input
            v-model="form.allocatedQuantity"
            placeholder="请输入调拨数量"
          />
        </el-form-item>
        <el-form-item label="基本单位调拨数量" prop="allocatedNum">
          <el-input
            v-model="form.allocatedNum"
            placeholder="请输入基本单位调拨数量"
          />
        </el-form-item>
        <el-form-item label="调拨选单数量" prop="transferQuantity">
          <el-input
            v-model="form.transferQuantity"
            placeholder="请输入调拨选单数量"
          />
        </el-form-item>
        <el-form-item label="基本单位调拨选单数量" prop="transferNum">
          <el-input
            v-model="form.transferNum"
            placeholder="请输入基本单位调拨选单数量"
          />
        </el-form-item>
        <el-form-item label="变更次数" prop="becomeQuantity">
          <el-input
            v-model="form.becomeQuantity"
            placeholder="请输入变更次数"
          />
        </el-form-item>
        <el-form-item label="计划模式" prop="planMode">
          <el-input v-model="form.planMode" placeholder="请输入计划模式" />
        </el-form-item>
        <el-form-item label="打印次数" prop="printNumber">
          <el-input v-model="form.printNumber" placeholder="请输入打印次数" />
        </el-form-item>
        <el-form-item label="计划跟踪单号" prop="teackNumber">
          <el-input
            v-model="form.teackNumber"
            placeholder="请输入计划跟踪单号"
          />
        </el-form-item>
        <el-form-item label="位置号" prop="locationNumber">
          <el-input v-model="form.locationNumber" placeholder="请输入位置号" />
        </el-form-item>
        <el-form-item label="还料尺寸" prop="returnDimension">
          <el-input
            v-model="form.returnDimension"
            placeholder="请输入还料尺寸"
          />
        </el-form-item>
        <el-form-item label="还料数" prop="returnQuantity">
          <el-input v-model="form.returnQuantity" placeholder="请输入还料数" />
        </el-form-item>
        <el-form-item label="产品辅助属性" prop="productProperties">
          <el-input
            v-model="form.productProperties"
            placeholder="请输入产品辅助属性"
          />
        </el-form-item>
        <el-form-item label="产品辅助属性代码" prop="propertiesCode">
          <el-input
            v-model="form.propertiesCode"
            placeholder="请输入产品辅助属性代码"
          />
        </el-form-item>
        <el-form-item label="物料辅助属性" prop="materialProperties">
          <el-input
            v-model="form.materialProperties"
            placeholder="请输入物料辅助属性"
          />
        </el-form-item>
        <el-form-item label="物料辅助属性代码" prop="materialCode">
          <el-input
            v-model="form.materialCode"
            placeholder="请输入物料辅助属性代码"
          />
        </el-form-item>
        <el-form-item label="下达车间" prop="releaseWorkshop">
          <el-input
            v-model="form.releaseWorkshop"
            placeholder="请输入下达车间"
          />
        </el-form-item>
        <el-form-item label="客户料号" prop="customerItem">
          <el-input v-model="form.customerItem" placeholder="请输入客户料号" />
        </el-form-item>
        <el-form-item label="助记码" prop="mnemonicCode">
          <el-input v-model="form.mnemonicCode" placeholder="请输入助记码" />
        </el-form-item>
        <el-form-item
          label="调拨状态(1=待调拨，2=调拨中，3=已完成)"
          prop="transferStatus"
        >
          <el-select
            v-model="form.transferStatus"
            placeholder="请选择调拨状态(1=待调拨，2=调拨中，3=已完成)"
          >
            <el-option
              v-for="dict in transferStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="单据状态(1=创建，2=完成)" prop="documentStatus">
          <el-select
            v-model="form.documentStatus"
            placeholder="请选择单据状态(1=创建，2=完成)"
          >
            <el-option
              v-for="dict in documentStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="上料数" prop="upgoodsNum">
          <el-input v-model="form.upgoodsNum" placeholder="请输入上料数" />
        </el-form-item>
        <el-form-item label="存在替代关系" prop="existReplace">
          <el-input
            v-model="form.existReplace"
            placeholder="请输入存在替代关系"
          />
        </el-form-item>
        <el-form-item label="来源" prop="source">
          <el-input v-model="form.source" placeholder="请输入来源" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
       <!-- 备料对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open1"
      width="1000px"
      append-to-body
    >
      <el-form ref="form1" :model="form1" :rules="rules1" label-width="80px">
 <el-form-item label="单据状态" prop="documentStatus">
          <el-select
            v-model="form1.documentStatus"
            placeholder="请选择单据状态(1=创建，2=完成)"
          >
            <el-option
              v-for="dict in documentStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="调拨单号" prop="transferNo">
          <el-input v-model="form1.transferNo" placeholder="调拨单号" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input
            v-model="form1.remark"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>

            <el-table
      v-loading="loading"
      :data="multipleTable"
      @selection-change="handleSelectionChange"
             :default-sort="{ prop: 'date', order: 'descending' }"
      ref="tableDatas"
      
      >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="工单类型(0正常，1超产，2返工)" align="center" prop="workorderType" :formatter="workorderTypeFormat" sortable width="150"/>
      <el-table-column label="生产工单号" align="center" prop="prodorderNo" sortable width="150"/>
      <el-table-column label="产品id" align="center" prop="productId" sortable width="150"/>
      <el-table-column label="产品编码" align="center" prop="productCode" sortable width="150"/>
      <el-table-column label="产品名称" align="center" prop="productName" sortable width="150"/>
      <el-table-column label="规格型号" align="center" prop="specModel" sortable width="150"/>
      <el-table-column label="单位" align="center" prop="unit" sortable width="150"/>
      <el-table-column label="车间" align="center" prop="workshop" sortable width="150"/>
      <el-table-column label="产线" align="center" prop="prodLine" sortable width="150"/>
      <el-table-column label="数量" align="center" prop="quantity" sortable width="150"/>
      <el-table-column label="物料id" align="center" prop="goodsId" sortable width="150"/>
      <el-table-column label="物料名称" align="center" prop="goodsName" sortable width="150"/>
      <el-table-column label="计划生产数量" align="center" prop="needQuantity" sortable width="150"/>
      <el-table-column label="物料规格型号" align="center" prop="goodsModel" sortable width="150"/>
      <el-table-column label="物料编码" align="center" prop="goodsCode" sortable width="150"/>
      <el-table-column label="物料单位" align="center" prop="goodsUnit" sortable width="150"/>
      <el-table-column label="应投数量" align="center" prop="investedQuantity" sortable width="150"/>
      <el-table-column label="单位用量" align="center" prop="unitDosage" sortable width="150"/>
      <el-table-column label="应投数量" align="center" prop="yfNum" sortable width="150"/>
      <el-table-column label="标准用量" align="center" prop="standardDosage" sortable width="150"/>
      <el-table-column label="应发数量" align="center" prop="issuedQuantity" sortable width="150"/>
      <el-table-column label="物料类型" align="center" prop="goodsType" :formatter="goodsTypeFormat" sortable width="150"/>
      <el-table-column label="已备料数量" align="center" prop="receivedQuantity" sortable width="150"/>
<el-table-column label="备料数量" prop="investedQuantity" sortable width="150">
  <template scope="scope">
      <span>
        <el-input v-model="scope.row.investedQuantity" placeholder="请输入备料数量">
          </el-input>
          </span>
            </template>
        </el-table-column>
      <el-table-column label="投料单号" align="center" prop="goodsStagingno" sortable width="150"/>
      <el-table-column label="销售订单号" align="center" prop="saleNum" sortable width="150"/>
      <el-table-column label="计划单号" align="center" prop="playNo" sortable width="150"/>
      <el-table-column label="备料状态" align="center" prop="stockState" :formatter="stockStateFormat" sortable width="150"/>

             <el-table-column label="发料仓库" prop="issueWarehouse" sortable width="150">
               <template scope="scope">
                 <span>
          <el-select
            v-model="scope.row.issueWarehouse"
            placeholder="请选择发料仓库"
            style="width: 100%"
          >
            <el-option
              v-for="dict in WareOptions[scope.row.goodsId]"
              :key="dict.issueId"
              :label="`${dict.name}`"
              :value="`${dict.warehouseId}|${dict.name}`"
            ></el-option>
          </el-select>
          </span>
          </template>
        </el-table-column>
        
             <el-table-column label="收料仓库" prop="receiveWarehouse" sortable width="150">
               <template scope="scope">
                 <span>
          <el-select
            v-model="scope.row.receiveWarehouse"
            placeholder="请选择收料仓库"
            style="width: 100%"
            
          >
            <el-option
              v-for="dict in receiveOptions"
              :key="dict.receiveId"
              :label="`${dict.name}`"
              :value="`${dict.warehouseId}|${dict.name}`"
            ></el-option>
          </el-select>
          </span>
          </template>
        </el-table-column>
<!-- 
            <el-table-column label="收料仓库" prop="receiveWarehouse" sortable width="150">
  <template scope="scope">
      <span>
        
          <el-select
                v-model="scope.row.receiveWarehouse"
                placeholder="请选择收料仓库"
              >
                <el-option
                  v-for="dict in WarehouseOptions"
                  :key="dict.name"
                  :label="dict.name"
                  :value="dict.name"
                ></el-option>
              </el-select>
          </span>
            </template>
        </el-table-column> -->
      <el-table-column label="产品辅助属性" align="center" prop="productProperties" sortable width="150"/>
      <el-table-column label="产品辅助属性代码" align="center" prop="propertiesCode" sortable width="150"/>
      <el-table-column label="物料辅助属性" align="center" prop="materialProperties" sortable width="150"/>
      <el-table-column label="物料辅助属性代码" align="center" prop="materialCode" sortable width="150"/>
      <el-table-column label="客户料号" align="center" prop="customerItem" sortable width="150"/>
      <el-table-column label="班组" align="center" prop="team"  sortable width="150"/>
      <el-table-column label="班次" align="center" prop="frequency"  sortable width="150"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['prodplan:feeding:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['prodplan:feeding:remove']"
          >删除</el-button>
        </template>
      </el-table-column> 
    </el-table>
    
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      
    />




      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="IssueForm">发 料</el-button>
        <el-button
          type="primary"
          @click="retainForm"
          v-hasPermi="['prodmanage:mworkorder:retain']"
          >保 存</el-button
        >
        <el-button
          type="primary"
          @click="receivForm"
          v-hasPermi="['prodmanage:mworkorder:received']"
          >收 料</el-button
        >
        <el-button @click="cancel1">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 上料对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open2"
      width="1000px"
      append-to-body
    >
      <el-form ref="form2" :model="form2" :rules="rules2" label-width="80px">
        <el-row>
                    <el-col :span="6">
            <el-form-item label="工单类型" prop="workorderType">
              <el-select
                v-model="form2.workorderType"
                placeholder="请选择工单类型"
                :disabled="true"
              >
                <el-option
                  v-for="dict in workorderTypeOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="调拨状态" prop="transferStatus">
              <el-select
                v-model="form2.transferStatus"
                placeholder="请选择调拨状态"
                :disabled="true"
              >
                <el-option
                  v-for="dict in transferStatusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="单据状态" prop="documentStatus">
              <el-select
                v-model="form2.documentStatus"
                placeholder="请选择单据状态"
                :disabled="true"
              >
                <el-option
                  v-for="dict in documentStatusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="产品编码" prop="productCode">
              <el-input
                v-model="form2.productCode"
                placeholder="请输入产品编码"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
                  </el-row
        >
        <el-row>
                    <el-col :span="6">
            <el-form-item label="产品名称" prop="productName">
              <el-input
                v-model="form2.productName"
                placeholder="请输入产品名称"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
                  <el-col :span="6">
            <el-form-item label="规格型号" prop="specModel">
              <el-input
                v-model="form2.specModel"
                placeholder="请输入规格型号"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
                  <el-col :span="6">
            <el-form-item label="数量" prop="quantity">
              <el-input v-model="form2.quantity" placeholder="请输入数量" :disabled="true"/>
            </el-form-item>
          </el-col>
                  <el-col :span="6">
            <el-form-item label="单位" prop="unit">
              <el-input v-model="form2.unit" placeholder="请输入单位" :disabled="true"/>
            </el-form-item>
          </el-col>
                  </el-row
        >
        <el-row>
                    <el-col :span="6">
            <el-form-item label="车间" prop="workshop">
              <el-input v-model="form2.workshop" placeholder="请输入车间" :disabled="true"/>
            </el-form-item>
          </el-col>
                  <el-col :span="6">
            <el-form-item label="物料编码" prop="goodsCode">
              <el-input
                v-model="form2.goodsCode"
                placeholder="请输入物料编码" :disabled="true"
              />
            </el-form-item>
          </el-col>
                  <el-col :span="6">
            <el-form-item label="物料名称" prop="goodsName">
              <el-input
                v-model="form2.goodsName"
                placeholder="请输入物料名称" :disabled="true"
              />
            </el-form-item>
          </el-col>
                  <el-col :span="6">
            <el-form-item label="物料规格" prop="goodsModel">
              <el-input
                v-model="form2.goodsModel"
                placeholder="请输入物料规格" :disabled="true"
              />
            </el-form-item>
          </el-col>
                  </el-row
        >
        <el-row>
                    <el-col :span="6">
            <el-form-item label="物料单位" prop="goodsUnit">
              <el-input
                v-model="form2.goodsUnit"
                placeholder="请输入物料单位" :disabled="true"
              />
            </el-form-item>
          </el-col>
                  <el-col :span="6">
            <el-form-item label="单位用量" prop="unitDosage">
              <el-input
                v-model="form2.unitDosage" 
                placeholder="请输入单位用量" :disabled="true"
              />
            </el-form-item>
          </el-col>
                  <el-col :span="6">
            <el-form-item label="已领数量" prop="receivedQuantity">
              <el-input
                v-model="form2.receivedQuantity"
                placeholder="请输入已领数量" :disabled="true"
              />
            </el-form-item>
          </el-col>
                  <el-col :span="6">
            <el-form-item label="可用库存" prop="avaInventory">
              <el-input
                v-model="form2.avaInventory"
                placeholder="请输入可用库存" :disabled="true"
              />
            </el-form-item>
          </el-col>
                  </el-row
        >
        <el-row>
                    <el-col :span="6">
            <el-form-item label="上料数" prop="upgoodsNum">
              <el-input v-model="form2.upgoodsNum" placeholder="请输入上料数" />
            </el-form-item>
          </el-col>
                  <el-col :span="6">
            <el-form-item label="生产工单" prop="prodorderNo">
              <el-input
                v-model="form2.prodorderNo"
                placeholder="请输入生产工单" :disabled="true"
              />
            </el-form-item>
          </el-col>
                  <el-col :span="6">
            <el-form-item label="备料状态" prop="stockState">
              <el-select
                v-model="form2.stockState"
                placeholder="请选择备料状态" :disabled="true"
              >
                <el-option
                  v-for="dict in stockStateOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
                  <el-col :span="6">
            <el-form-item label="收料仓库" prop="receiveWarehouse">
              <el-input
                v-model="form2.receiveWarehouse"
                placeholder="请输入收料仓库" :disabled="true"
              />
            </el-form-item>
          </el-col>
                  </el-row
        >
        <el-row>
                    <el-col :span="6">
            <el-form-item label="收料人" prop="receiveBy">
              <el-input v-model="form2.receiveBy" placeholder="请输入收料人" :disabled="true"/>
            </el-form-item>
          </el-col>
                  <el-col :span="6">
            <el-form-item label="收料时间" prop="receiveTime">
              <el-date-picker
                clearable
                size="small"
                style="width: 200px"
                v-model="form2.receiveTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择收料时间" :disabled="true"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
                  </el-row
        >

        <el-form-item label="备注" prop="remark">
          <el-input
            v-model="form2.remark"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitUp">提交</el-button>
        <el-button @click="cancel2">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  loadingMworkorder,
  retainMworkorder,
  receivedMworkorder,
  readyMworkorder,
  listMworkorder,
  getMworkorder,
  delMworkorder,
  addMworkorder,
  updateMworkorder,
  exportMworkorder,
  listWarehouse,
  listStock,
  listStockId,

} from "@/api/prodmanage/mworkorder";

export default {
  name: "Mworkorder",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      //发料仓库
      WarehouseOptions: [],
      //收料仓库
      receiveOptions: [],
      // 工单信息表格数据
      mworkorderList: [],
      //备料表格数据
      mworkorder: [],
      // 弹出层标题
      title: "",
      receivedQuantity: "",

      issuedQuantity: "",
      // 是否显示弹出层
      open: false,
      open1: false,
      open2: false,
      // 工单类型(0正常，1超产，2返工)字典
      workorderTypeOptions: [],
      // 审核标志字典
      auditMarkOptions: [],
      // 物料类型字典
      goodsTypeOptions: [],
      // 执行状态字典
      exeStatusOptions: [],
      // 单据状态(0正常，1挂起，2关闭)字典
      docStatusOptions: [],
      // 生产类型(0普通订单，1新增订单，2MRP拉取)字典
      prodTypeOptions: [],
      // 状态类型(0=良品 1=不良品 2=待检品)字典
      stateTypeOptions: [],
      // 备料状态字典
      stockStateOptions: [],
      // 调拨状态(1=待调拨，2=调拨中，3=已完成)字典
      transferStatusOptions: [],
      // 单据状态(1=创建，2=完成)字典
      documentStatusOptions: [],
      //备料数组
      readyOptions: [],
      //备料数量
      quantityOptions: [],
      //调拨状态
      transferOptions: [],
      //数量
      avaOptions: [],
      //存放选中值的数组
      multipleTable: [],
      //发料仓库
      WareOptions:[[]],
      //合并记录的行列
      rowspans: [],
      //记录需要合并的行位置
      posi: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        workorderType: undefined,
        productId: undefined,
        productCode: undefined,
        productName: undefined,
        specModel: undefined,
        unit: undefined,
        workshop: undefined,
        auditMark: undefined,
        auditMan: undefined,
        auditDate: undefined,
        quantity: undefined,
        goodsId: undefined,
        goodsName: undefined,
        goodsModel: undefined,
        goodsCode: undefined,
        goodsUnit: undefined,
        investedQuantity: undefined,
        unitDosage: undefined,
        exeStatus: undefined,
        docStatus: undefined,
        prodType: undefined,
        standardDosage: undefined,
        issuedQuantity: undefined,
        receivedQuantity: undefined,
        scrapQuantity: undefined,
        replenQuantity: undefined,
        lossRate: undefined,
        goodsType: undefined,
        prodorderNo: undefined,
        goodsStagingno: undefined,
        saleNum: undefined,
        playNo: undefined,
        plannedIssuedate: undefined,
        actualIssuedate: undefined,
        preparationDate: undefined,
        stateType: undefined,
        stockState: undefined,
        issueWarehouse: undefined,
        issuedBy: undefined,
        issueTime: undefined,
        receiveWarehouse: undefined,
        receiveBy: undefined,
        receiveTime: undefined,
        orderNum: undefined,
        levelName: undefined,
        createTime: undefined,
        createUser: undefined,
        updateTime: undefined,
        updateUser: undefined,
        isDel: undefined,
        remark: undefined,
        commentUnit: undefined,
        standardNum: undefined,
        planfeedNum: undefined,
        menuNum: undefined,
        basicunitInnum: undefined,
        inworkNum: undefined,
        consumNum: undefined,
        recoil: undefined,
        batch: undefined,
        lineorderCode: undefined,
        entryNum: undefined,
        basicunitNum: undefined,
        commentunitNum: undefined,
        workcompany: undefined,
        forbidden: undefined,
        subgoodsType: undefined,
        subgoodsCode: undefined,
        basicUnit: undefined,
        keyParts: undefined,
        useStatus: undefined,
        basicunitDosage: undefined,
        basicunitOutnum: undefined,
        basicunitBzdosage: undefined,
        realLossrate: undefined,
        basicLossnum: undefined,
        lossnum: undefined,
        basicplanNum: undefined,
        basicunitQuantity: undefined,
        basicunitScrapnum: undefined,
        scrapnum: undefined,
        basicunitConsumnum: undefined,
        basicunitInworknum: undefined,
        workProcess: undefined,
        workStation: undefined,
        lockFlag: undefined,
        lockNum: undefined,
        basicunitLocknum: undefined,
        basicunitUpnum: undefined,
        makeupNum: undefined,
        processNum: undefined,
        customerBom: undefined,
        allocatedQuantity: undefined,
        allocatedNum: undefined,
        transferQuantity: undefined,
        transferNum: undefined,
        becomeQuantity: undefined,
        planMode: undefined,
        printNumber: undefined,
        teackNumber: undefined,
        locationNumber: undefined,
        returnDimension: undefined,
        returnQuantity: undefined,
        productProperties: undefined,
        propertiesCode: undefined,
        materialProperties: undefined,
        materialCode: undefined,
        releaseWorkshop: undefined,
        customerItem: undefined,
        mnemonicCode: undefined,
        transferStatus: undefined,
        documentStatus: undefined,
        upgoodsNum: undefined,
        existReplace: undefined,
        avaInventory: undefined,
        source: undefined,
        receiveId: undefined,
        issueId: undefined,
      },
      //备料弹窗查询信息
      //  queryParams1: {
      //   pageNum: 1,
      //   pageSize: 10,
      //   feedingId: undefined,
      // },
      // 表单参数
      form: {},
      form1: {},
      form2: {},
      // 表单校验
      rules: {},
      rules1: {},
      rules2: {},
    };
  },
  created() {
    this.getList();

    this.getDicts("prodplan_feeding_workorder_type").then((response) => {
      this.workorderTypeOptions = response.data;
    });
    this.getDicts("prodplan_feeding_audit_mark").then((response) => {
      this.auditMarkOptions = response.data;
    });
    this.getDicts("prodplan_feeding_exe_status").then((response) => {
      this.exeStatusOptions = response.data;
    });
    this.getDicts("prodplan_workorder_doc_status").then((response) => {
      this.docStatusOptions = response.data;
    });
    this.getDicts("prodplan_feeding_prod_type").then((response) => {
      this.prodTypeOptions = response.data;
    });
    this.getDicts("prodplan_feeding_state_type").then((response) => {
      this.stateTypeOptions = response.data;
    });
    this.getDicts("prodplan_feeding_stock_state").then((response) => {
      this.stockStateOptions = response.data;
    });
    this.getDicts("prodplan_feeding_transfer_status").then((response) => {
      this.transferStatusOptions = response.data;
    });
    this.getDicts("prodplan_feeding_document_status").then((response) => {
      this.documentStatusOptions = response.data;
    });
    this.getDicts("prodmanage_workoreder_goods_type").then((response) => {
      this.goodsTypeOptions = response.data;
    });
  },
  methods: {
    // getlistWarehouse() {
    //   listWarehouse().then((response) => {
    //     this.WarehouseOptions = response.rows;
    //   });
    // },
      capitalize: function (value) {
    return this.selectDictLabel(this.workorderTypeOptions, value);},

      getstockId() {
      listStockId().then((response) => {
              
        this.receiveOptions = response.rows;
        
      });
    },
  getstock() {
              this.multipleTable.forEach(item => {
                  listStock(item.goodsId).then((response) => {
              this.WareOptions[item.goodsId] = response.rows;
              console.log(item.goodsId)
              // this.WarehouseOptions = response.rows;
        
      });
          }); 

    },
    IsHidden(rowIndex) {
     
      if (this.rowspans[rowIndex] == 1) {
        return true;
      } else {
        return false;
      }
    },

    spanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 0) {
        const _row = this.rowspans[rowIndex];
        const _col = _row > 0 ? 1 : 0;
        return {
          rowspan: _row,
          colspan: _col,
        };
      }
    },
    /** 查询工单信息列表 */
    getList() {
      this.loading = true;
      listMworkorder(this.queryParams).then((response) => {
        this.mworkorderList = response.rows;

        for (let i in this.mworkorderList) {
          if (i == 0) {
            //1代表真 显示     0代表假 隐藏
            this.rowspans.push(1);
            // this.posi = 0;
          } else {
            if (
              this.mworkorderList[i].prodorderNo ===
              this.mworkorderList[i - 1].prodorderNo
            ) {
              this.rowspans.push(0);
            } else {
              this.rowspans.push(1);
            }
          }
        }
        
        this.total = response.total;

        this.loading = false;
      });
    },
   

    // 工单类型(0正常，1超产，2返工)字典翻译
    workorderTypeFormat(row, column) {
      return this.selectDictLabel(this.workorderTypeOptions, row.workorderType);
    },
    // 审核标志字典翻译
    auditMarkFormat(row, column) {
      return this.selectDictLabel(this.auditMarkOptions, row.auditMark);
    },
    // 执行状态字典翻译
    exeStatusFormat(row, column) {
      return this.selectDictLabel(this.exeStatusOptions, row.exeStatus);
    },
    // 单据状态(0正常，1挂起，2关闭)字典翻译
    docStatusFormat(row, column) {
      return this.selectDictLabel(this.docStatusOptions, row.docStatus);
    },
    // 生产类型(0普通订单，1新增订单，2MRP拉取)字典翻译
    prodTypeFormat(row, column) {
      return this.selectDictLabel(this.prodTypeOptions, row.prodType);
    },
    // 状态类型(0=良品 1=不良品 2=待检品)字典翻译
    stateTypeFormat(row, column) {
      return this.selectDictLabel(this.stateTypeOptions, row.stateType);
    },
    // 备料状态字典翻译
    stockStateFormat(row, column) {
      return this.selectDictLabel(this.stockStateOptions, row.stockState);
    },
    // 物料类型字典翻译
    goodsTypeFormat(row, column) {
      return this.selectDictLabel(this.goodsTypeOptions, row.goodsType);
    },
    // 调拨状态(1=待调拨，2=调拨中，3=已完成)字典翻译
    transferStatusFormat(row, column) {
      return this.selectDictLabel(
        this.transferStatusOptions,
        row.transferStatus
      );
    },
    // 单据状态(1=创建，2=完成)字典翻译
    documentStatusFormat(row, column) {
      return this.selectDictLabel(
        this.documentStatusOptions,
        row.documentStatus
      );
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    cancel1() {
      this.open1 = false;
      this.reset1();
    },
    cancel2() {
      this.open2 = false;
      this.reset2();
    },
    // 表单重置
    reset() {
      this.form = {
        feedingId: undefined,
        workorderType: undefined,
        productId: undefined,
        productCode: undefined,
        productName: undefined,
        specModel: undefined,
        unit: undefined,
        workshop: undefined,
        auditMark: undefined,
        auditMan: undefined,
        auditDate: undefined,
        quantity: undefined,
        goodsId: undefined,
        goodsName: undefined,
        goodsModel: undefined,
        goodsCode: undefined,
        goodsUnit: undefined,
        investedQuantity: undefined,
        unitDosage: undefined,
        exeStatus: undefined,
        docStatus: undefined,
        prodType: undefined,
        standardDosage: undefined,
        issuedQuantity: undefined,
        receivedQuantity: undefined,
        scrapQuantity: undefined,
        replenQuantity: undefined,
        lossRate: undefined,
        goodsType: undefined,
        prodorderNo: undefined,
        goodsStagingno: undefined,
        saleNum: undefined,
        playNo: undefined,
        plannedIssuedate: undefined,
        actualIssuedate: undefined,
        preparationDate: undefined,
        stateType: undefined,
        stockState: undefined,
        issueWarehouse: undefined,
        issuedBy: undefined,
        issueTime: undefined,
        receiveWarehouse: undefined,
        receiveBy: undefined,
        receiveTime: undefined,
        orderNum: undefined,
        levelName: undefined,
        createTime: undefined,
        createUser: undefined,
        updateTime: undefined,
        updateUser: undefined,
        isDel: undefined,
        remark: undefined,
        commentUnit: undefined,
        standardNum: undefined,
        planfeedNum: undefined,
        menuNum: undefined,
        basicunitInnum: undefined,
        inworkNum: undefined,
        consumNum: undefined,
        recoil: undefined,
        batch: undefined,
        lineorderCode: undefined,
        entryNum: undefined,
        basicunitNum: undefined,
        commentunitNum: undefined,
        workcompany: undefined,
        forbidden: undefined,
        subgoodsType: undefined,
        subgoodsCode: undefined,
        basicUnit: undefined,
        keyParts: undefined,
        useStatus: "0",
        basicunitDosage: undefined,
        basicunitOutnum: undefined,
        basicunitBzdosage: undefined,
        realLossrate: undefined,
        basicLossnum: undefined,
        lossnum: undefined,
        basicplanNum: undefined,
        basicunitQuantity: undefined,
        basicunitScrapnum: undefined,
        scrapnum: undefined,
        basicunitConsumnum: undefined,
        basicunitInworknum: undefined,
        workProcess: undefined,
        workStation: undefined,
        lockFlag: undefined,
        lockNum: undefined,
        basicunitLocknum: undefined,
        basicunitUpnum: undefined,
        makeupNum: undefined,
        processNum: undefined,
        customerBom: undefined,
        allocatedQuantity: undefined,
        allocatedNum: undefined,
        transferQuantity: undefined,
        transferNum: undefined,
        becomeQuantity: undefined,
        planMode: undefined,
        printNumber: undefined,
        teackNumber: undefined,
        locationNumber: undefined,
        returnDimension: undefined,
        returnQuantity: undefined,
        productProperties: undefined,
        propertiesCode: undefined,
        materialProperties: undefined,
        materialCode: undefined,
        releaseWorkshop: undefined,
        customerItem: undefined,
        mnemonicCode: undefined,
        transferStatus: undefined,
        documentStatus: 0,
        upgoodsNum: undefined,
        existReplace: undefined,
        avaInventory: undefined,
        source: undefined,
                receiveId: undefined,
        issueId: undefined,
      };
      this.resetForm("form");
    },

     reset1() {
      this.form1 = {
        transferId: undefined,
        transferStatus: undefined,
        transferNo: undefined,
        workNo: undefined,
        documentStatus: undefined,
        goodsId: undefined,
        transferNumber: undefined,
        issueWarehouse: undefined,
        issueBy: undefined,
        issueTime: undefined,
        receiveWarehouse: undefined,
        receiveBy: undefined,
        receiveTime: undefined,
        createTime: undefined,
        createUser: undefined,
        updateTime: undefined,
        updateUser: undefined,
        isDel: undefined,
        remark: undefined,
                receiveId: undefined,
        issueId: undefined,
      };
      this.resetForm("form1");
    },

    reset2() {
      this.form2 = {
        feedingId: undefined,
        workorderType: undefined,
        productId: undefined,
        productCode: undefined,
        productName: undefined,
        specModel: undefined,
        unit: undefined,
        workshop: undefined,
        auditMark: undefined,
        auditMan: undefined,
        auditDate: undefined,
        quantity: undefined,
        goodsId: undefined,
        goodsName: undefined,
        goodsModel: undefined,
        goodsCode: undefined,
        goodsUnit: undefined,
        investedQuantity: undefined,
        unitDosage: undefined,
        exeStatus: undefined,
        docStatus: undefined,
        prodType: undefined,
        standardDosage: undefined,
        issuedQuantity: undefined,
        receivedQuantity: undefined,
        scrapQuantity: undefined,
        replenQuantity: undefined,
        lossRate: undefined,
        goodsType: undefined,
        prodorderNo: undefined,
        goodsStagingno: undefined,
        saleNum: undefined,
        playNo: undefined,
        plannedIssuedate: undefined,
        actualIssuedate: undefined,
        preparationDate: undefined,
        stateType: undefined,
        stockState: undefined,
        issueWarehouse: undefined,
        issuedBy: undefined,
        issueTime: undefined,
        receiveWarehouse: undefined,
        receiveBy: undefined,
        receiveTime: undefined,
        orderNum: undefined,
        levelName: undefined,
        createTime: undefined,
        createUser: undefined,
        updateTime: undefined,
        updateUser: undefined,
        isDel: undefined,
        remark: undefined,
        commentUnit: undefined,
        standardNum: undefined,
        planfeedNum: undefined,
        menuNum: undefined,
        basicunitInnum: undefined,
        inworkNum: undefined,
        consumNum: undefined,
        recoil: undefined,
        batch: undefined,
        lineorderCode: undefined,
        entryNum: undefined,
        basicunitNum: undefined,
        commentunitNum: undefined,
        workcompany: undefined,
        forbidden: undefined,
        subgoodsType: undefined,
        subgoodsCode: undefined,
        basicUnit: undefined,
        keyParts: undefined,
        useStatus: "0",
        basicunitDosage: undefined,
        basicunitOutnum: undefined,
        basicunitBzdosage: undefined,
        realLossrate: undefined,
        basicLossnum: undefined,
        lossnum: undefined,
        basicplanNum: undefined,
        basicunitQuantity: undefined,
        basicunitScrapnum: undefined,
        scrapnum: undefined,
        basicunitConsumnum: undefined,
        basicunitInworknum: undefined,
        workProcess: undefined,
        workStation: undefined,
        lockFlag: undefined,
        lockNum: undefined,
        basicunitLocknum: undefined,
        basicunitUpnum: undefined,
        makeupNum: undefined,
        processNum: undefined,
        customerBom: undefined,
        allocatedQuantity: undefined,
        allocatedNum: undefined,
        transferQuantity: undefined,
        transferNum: undefined,
        becomeQuantity: undefined,
        planMode: undefined,
        printNumber: undefined,
        teackNumber: undefined,
        locationNumber: undefined,
        returnDimension: undefined,
        returnQuantity: undefined,
        productProperties: undefined,
        propertiesCode: undefined,
        materialProperties: undefined,
        materialCode: undefined,
        releaseWorkshop: undefined,
        customerItem: undefined,
        mnemonicCode: undefined,
        transferStatus: undefined,
        documentStatus: undefined,
        upgoodsNum: undefined,
        existReplace: undefined,
        avaInventory: undefined,
        source: undefined,
                receiveId: undefined,
        issueId: undefined,
      };
      this.resetForm("form2");
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.feedingId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
      this.readyOptions = selection;
      this.quantityOptions = selection;
      this.transferOptions = selection;
      this.avaOptions = selection;
      this.multipleTable = selection;

     
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加工单信息";
    },
    /** 备料按钮操作 */
    ready(row) {
      
              
       this.reset1();
      this.getstock();
      
      
      var aa = this.multipleTable.map(item => item.feedingId)[0];
             var bb = parseInt(aa);
       var feedingId =bb ;
      
      var isLock = this.readyOptions.map((item) => item.exeStatus)[0];
      var doc = this.readyOptions.map((item) => item.docStatus)[0];
      if (doc == 1 || doc == 2) {
        this.msgSuccess("该订单已挂起不能备料");
        return;
      }
      if (isLock == 0 || isLock == 3 || isLock == 4) {
        
        this.msgSuccess("当前状态不能备料");
        return;
      }
      getMworkorder(feedingId).then((response) => {
        this.getstockId();
        this.form2 = response.data;
        this.form1 = response.data;
        this.open1 = true;
        this.title = "备 料";
        });
    },

   

    /** 收料按钮操作 */
    receivForm() {
      var transfer = this.transferOptions.map((item) => item.transferStatus)[0];
                  let tmp2 = this.form1.receiveWarehouse.split("|"); 
            this.form1.receiveId = parseInt(tmp2[0]);
            this.form1.receiveWarehouse = tmp2[1];
      this.$refs["form1"].validate((valid) => {
        if (valid) {
          
          if (transfer == 0) {
            this.msgSuccess("当前不可收料，请查看是否发料");
            return;
          }
          if (transfer == 2) {
            this.msgSuccess("当前已收料，请勿重复收料");
            return;
          }
                this.multipleTable.forEach(item => {
      
            receivedMworkorder({"pf":item,"wt":this.form1}).then((response) => {
            this.msgSuccess("收料成功");
            this.open1 = false;
            this.getList();
          });
          }); 
        }
      });
    },

 /** 发料按钮操作 */
    IssueForm() {
      
      this.$refs["form1"].validate((valid) => {
    if (valid) {
        

      this.multipleTable.forEach(item => {
        if(item.issueWarehouse!=null && item.receiveWarehouse!=null ){
          let tmp1 = item.issueWarehouse.split("|");
            item.issueId = parseInt(tmp1[0]);
            item.issueWarehouse = tmp1[1];
           let tmp2 = item.receiveWarehouse.split("|");
           item.receiveId = parseInt(tmp2[0]);
            item.receiveWarehouse = tmp2[1];
        }
            readyMworkorder({"pf":item,"wt":this.form1}).then((response) => {
            this.msgSuccess("备料信息发送成功");
            this.open1 = false;
            this.getList();
          });
          }); 
          }
          });
      
    },
    /** 保存按钮操作 */
    retainForm() {
      var transfer = this.transferOptions.map((item) => item.transferStatus)[0];
           
                        let tmp1 = this.form1.issueWarehouse.split("|");
            this.form1.issueId = parseInt(tmp1[0]);
            this.form1.issueWarehouse = tmp1[1];

            //       let tmp2 = this.form1.receiveWarehouse.split("|");
            // this.form1.issueId = parseInt(tmp2[0]);
            // this.form1.issueWarehouse = tmp2[1];
      this.$refs["form1"].validate((valid) => {
        if (valid) {
          if (transfer == 0) {
            this.msgSuccess("请勿重复保存，请去调拨单中修改");
            return;
          }
          if (transfer == 1) {
            this.msgSuccess("已发料，请勿重复保存");
            return;
          }
          if (transfer == 2) {
            this.msgSuccess("已收料，请勿重复保存改");
            return;
          }
          this.multipleTable.forEach(item => {
          
            retainMworkorder({"pf":item,"wt":this.form1}).then((response) => {
            this.msgSuccess("保存成功，修改需找调拨单");
            this.open1 = false;
            this.getList();
          });
          }); 
        }
      });
    },


    /** 上料按钮操作 */
    upFrom(row) {
      this.reset2();
      const feedingId = row.feedingId || this.ids;
      var transfer = this.transferOptions.map((item) => item.transferStatus)[0];
      var isLock = this.readyOptions.map((item) => item.exeStatus)[0];
      var doc = this.readyOptions.map((item) => item.docStatus)[0];
      if (doc == 1 || doc == 2) {
        this.msgSuccess("该订单已挂起不能上料");
        return;
      }
      if (isLock == 0 || isLock == 3 || isLock == 5) {
        this.msgSuccess("当前状态不能上料");
        return;
      }
      if (transfer == 0 || transfer == 1) {
        this.msgSuccess("无法上料，未收料");
        return;
      }
      getMworkorder(feedingId).then((response2) => {
        this.form2 = response2.data;
       
        this.open2 = true;
        this.title = "上 料";
      });
    },
    /** 发料提交按钮 */
    submitUp() {
      var ava = this.avaOptions.map((item) => item.avaInventory)[0];
      var aa = parseInt(ava) - parseInt(this.form2.upgoodsNum);
      this.$refs["form2"].validate((valid) => {
        if (valid) {
          if (aa < 0) {
            this.msgSuccess("库存数量不足");
            return;
          }
          loadingMworkorder(this.form2).then((response) => {
            this.msgSuccess("上料成功");
            this.open2 = false;
            this.getList();
          });
        }
      });
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const feedingId = row.feedingId || this.ids;
      getMworkorder(feedingId).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改工单信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.feedingId != null) {
            updateMworkorder(this.form).then((response) => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addMworkorder(this.form).then((response) => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },

    /** 删除按钮操作 */
    handleDelete(row) {
      const feedingIds = row.feedingId || this.ids;
      this.$confirm(
        '是否确认删除工单信息编号为"' + feedingIds + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delMworkorder(feedingIds);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有工单信息数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return exportMworkorder(queryParams);
        })
        .then((response) => {
          this.download(response.msg);
        });
    },
  },
};
</script>